package stu4;

import java.util.Random;

public class StuTest {

    Student[] stus=new Student[10];
    //随机对象
    Random rad=new Random();
    public void initStus(){
        //初始化学生
        for (int i = 0; i < stus.length; i++) {
            //在空位置上赋予初始化对象
            stus[i]=new Student();
            stus[i].xuehao=i+1;
            stus[i].nianji=rad.nextInt(6)+1;
            stus[i].chengji=rad.nextInt(101);
        }
    }

    public void sort(){
        //冒泡排序
        for (int i = 0; i < stus.length; i++) {
            for (int j=0;j<stus.length-i-1;j++){
                if(stus[j].chengji>stus[j+1].chengji){
                    Student temp=stus[j];
                    stus[j]=stus[j+1];
                    stus[j+1]=temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        StuTest st=new StuTest();
        st.initStus();
    }

}
